package com.crazydream.wechat.system.service;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.crazydream.wechat.common.dao.BaseDAO;
import com.crazydream.wechat.common.vo.PageVo;
import com.crazydream.wechat.system.model.Resource;

@Service("resourceService")
public class ResourceService {

	@Autowired
	@Qualifier("dao")
	private BaseDAO dao;

	@Transactional
	public Resource findById(Resource model) {
		return dao.find(Resource.class,model.getId());
	}
	@Transactional
	public List<Resource> findForAll() {
		return dao.findWithNamedQuery(Resource.FIND_FOR_ALL);
	}
	@Transactional
	public PageVo<Resource> findForPageList(PageVo<Resource> page) {
	
		return page;
	}
	@Transactional
	public void modify(Resource model) {
		dao.update(model);
	}
	@Transactional
	public void removeById(Resource model) {
		dao.delete(Resource.class,model.getId());
	}
	@Transactional
	public void save(Resource model) {
		model.setCreatedate(new Date());
		model.setEnabled(1);
		this.dao.create(model);
	}

}
